"use strict";
var q = require('q');
var fs = require('fs');
var co = require('co');
var angleModel = require('./../../Model/Angle/index');
function AngleTest(portName) {
    var angleControl = new angleModel.AngleController(portName);
    // 测试设备列表
    var Point1 = new angleModel.AnglePoint(1, 0.01);
    var Point2 = new angleModel.AnglePoint(2, 0.001);
    angleControl.deviceList.push(Point1);
    angleControl.deviceList.push(Point2);
    co(function* () {
        yield q.delay(1000);
        for (let i = 0; i < 100; i++) {
            console.log(i + '-1');
            var results = yield angleControl.survey();
            console.log(i + '-2');
            results.forEach(AnglePoint => {
                console.log(i + '-3');
                // trySave(AnglePoint);
                console.log(i + '-4');
            });
        }
    });
}
exports.AngleTest = AngleTest;
/**
 * 保存测量结果到文本文件
 * @param pt-每个倾角计测量点
 */
function trySave(pt) {
    try {
        fs.appendFileSync('result.txt', `\r\nID:${pt.id},X:${pt.x.toFixed(4)},Y:${pt.y.toFixed(4)},Time:${pt.time.toLocaleString()}`);
    }
    catch (err) {
        console.log(err);
    }
}
